<template>
	<view class="content">
		<empty v-if="applicationRecord.length == 0"></empty>
		<view class="list" v-for="(item, index) in applicationRecord" :key="index" v-else>
			<view class="wrapper">
				<view class="left-box">
					<view class="address-box">
						<text class="address">{{item.communityEntity.areaName}}</text>
					</view>
					<view class="u-box">
						<text class="name">申请人：</text>
						<text>{{item.realName}}</text>
					</view>
					<view class="u-box">
						<label class="name">申请房间：</label>
						<text>{{item.roomInfo}}</text>
					</view>
					<view class="u-box">
						<label class="name">申请关系：</label>
						<text>{{item.relationId == "1001" ? "业主" : "成员"}}</text>
					</view>
					<view class="u-box">
						<text class="name">申请时间：</text>
						<text>{{item.createDate}}</text>
					</view>
					<view class="u-box" v-if="item.applicationStatus == '2'">
						<text class="name">拒绝理由：</text>
						<text>{{item.refuseReason}}</text>
					</view>
				</view>
				<view class="right-box">
					<text v-if="item.applicationStatus == '0'" class="tag0">审核中</text>
					<text v-if="item.applicationStatus == '1'" class="tag1">已通过</text>
					<text v-if="item.applicationStatus == '2'" class="tag2">已拒绝</text>
				</view>
			</view>
		</view>
		<!-- <button type="primary" class="button_class" @click="bindCommunity">绑定小区</button> -->
	</view>
</template>

<script>
	import empty from "@/components/empty";
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		components: {
			empty
		},
		data() {
			return {
				applicationRecord: []
			}
		},
		onLoad(option) {
			this.inquiryRecord()
		},
		onShow() {
			console.log(this.userInfo.userUuid)
		},
		computed: {
			...mapState(['hasLogin', 'userInfo'])
		},
		methods: {
			//查询申请记录
			inquiryRecord() {
				let that = this;
				let params = {
					userId: this.userInfo.userUuid
				}
				this.$api.request.searchUserApplicationsByUserId(params, res => {
					if (res.body.status.statusCode === '0') {
						that.applicationRecord = res.body.data.applicationEntities
					} else {
						this.$api.msg(res.body.status.errorDesc);
					}
				})
			},
			bindCommunity(){
				uni.navigateTo({
					url:"/package_mall/pages/user/bindCommunity"
				})
			}
		}
	}
</script>

<style lang='scss'>
	page {
		padding-bottom: 120upx;
		background: $page-color-base
	}

	.content {
		position: relative;
	}

	.list {
		display: flex;
		align-items: center;
		padding: 20upx 20upx;
		margin: 15upx 20upx;
		background: #ffffff;
		position: relative;
		border-radius: 16upx;
	}

	.wrapper {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		width: 100%
	}

	.left-box {}

	.right-box {
		padding-top: 10upx;
	}

	.tag0 {
		font-size: 24upx;
		color: #B0AEAE;
		background: #fffafb;
		border: 1px solid #B0AEAE;
		border-radius: 10upx;
		padding: 10upx 16upx;
		line-height: 1;
	}

	.tag1 {
		font-size: 24upx;
		color: #ABDCF6;
		background: #fffafb;
		border: 1px solid #ABDCF6;
		border-radius: 10upx;
		padding: 10upx 16upx;
		line-height: 1;
	}

	.tag2 {
		font-size: 24upx;
		color: #ffb4c7;
		background: #fffafb;
		border: 1px solid #ffb4c7;
		border-radius: 10upx;
		padding: 10upx 16upx;
		line-height: 1;
	}

	.address-box {
		display: flex;
		align-items: center;



		.address {
			font-size: 34upx;
			color: $font-color-dark;
			font-weight: bold;
		}
	}

	.u-box {
		font-size: 28upx;
		color: $font-color-light;
		margin-top: 16upx;

		.name {
			margin-right: 10upx;
			width: 150upx
		}
	}

	.icon-bianji {
		display: flex;
		align-items: center;
		height: 80upx;
		font-size: 40upx;
		color: $font-color-light;
		padding-left: 30upx;
	}

	.add-btn {
		position: fixed;
		left: 30upx;
		right: 30upx;
		bottom: 16upx;
		z-index: 95;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 690upx;
		height: 80upx;
		font-size: 32upx;
		color: #fff;
		background-color: $base-color;
		border-radius: 10upx;
		box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
	}

	/* 底部操作菜单 */
	.page-bottom {
		position: fixed;
		left: 30upx;
		bottom: 30upx;
		z-index: 95;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 690upx;
		height: 100upx;
		color: #FFFFFF;
		font-size: 34upx;
		letter-spacing: 2upx;
		background: linear-gradient(to right, #ffac30, #fa436a, #F56C6C);
		box-shadow: 0 0 20upx 0 rgba(0, 0, 0, .5);
		border-radius: 16upx;
	}
	
	.button_class {
		position: fixed;
		bottom: 40upx;
		margin-top: 20upx;
		width: 80%;
		margin-left: 10%;
		height: 80upx;
		line-height: 80upx;
		border-radius: 40upx;
		background-color: #1DA3EE !important;
		color: white
	}
</style>
